package ioperations;

import book.Book;
import book.BookList;
import user.AdminUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-24
 * Time: 20:38
 */
public class FindOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");

        int currentSize = bookList.getUsedSize();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的图书");
        String name = scanner.nextLine();

        for (int i = 0; i < currentSize; i++) {
            //遍历，书架，已初始化的书
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                System.out.println("找到了");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你要找的书...");
    }
}
